package com.gitee.sparta.common;

import com.gitee.sparta.core.cluster.ClusterCache;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

/**
 * <p>
 *      身份枚举
 * </p>
 *
 * @author zyred
 * @since v 1.0.0
 */
@Getter
@AllArgsConstructor
public enum IdentityEnum {

    /** 主节点 **/
    LEADER(1, "leader"),
    /** 从节点 **/
    FOLLOWER(2, "follower");

    private final int identity;
    private final String desc;

    public static boolean leader() {
        return Objects.equals(ClusterCache.getServerIdentity(), LEADER);
    }

}
